#ifndef NETWORK_SERVER_H
#define NETWORK_SERVER_H

#include <crow.h>
#include <functional>
#include <vector>
#include <thread>
#include <ImageType.hpp>
#include <map>
#include <mutex>

class networkServer_LogProxy : public crow::ILogHandler
{
  public:
    void log(std::string message,crow::LogLevel);
};

class NetworkServer
{
  public:
    NetworkServer();
    virtual ~NetworkServer();
    void Boot();

    std::function<long(const std::string & task_name)> funcCreateTask;
    std::function<void(long task_id,long stu_id)> funcStartRecord;
    std::function<std::tuple<bool,long>()> funcGetRecordStatus;
    std::function<void()> funcStopRecord;
    std::function<bool(long)> funcCheckStuExists;
    std::function<std::string(long)> funcGetStudentInf;
    std::function<void(bool)> funcTerminalConnectChange;
  private:
    crow::SimpleApp app;
    networkServer_LogProxy logProxy;
    std::thread netWorkThread;
    void netWorkFunc();
    crow::websocket::connection* handleImageSocket=nullptr;
    crow::websocket::connection* TerminalConnect=nullptr;
};

#endif
